﻿using System;
using System.Web.UI;
using InfoJetSoft.Service;
using ServBus.ListForm2010.Extension;

namespace ServBus.ListForm2010.ApplicationPages
{
    public partial class xdoc : System.Web.UI.Page
    {
        protected override void Render(HtmlTextWriter output)
        {  
            try
            {
                string publishUrl = this.Context.Request["xdoc_param_xsn_uri"];
                RelativeUrlResolver resolver = new RelativeUrlResolver(publishUrl);

                InfoJetContext ijCtx = new InfoJetContext();
                ijCtx.InlineFileStorage = new InlineFileStorage();
                ijCtx.RelativeUrlResolver = resolver;
                InfoJetForm form = InfoJetService.UpdateForm(this.Context, ijCtx);
                output.Write(form.Xhtml);
                output.Close();
            }
            catch (Exception e)
            {
                output.Write(e.Message + "<br>");
                output.Write(e.StackTrace);
                output.Close();
            }
        }
    }
}
